<!--
 * @Author: Meow
 * @Date: 2019-09-26 09:45:12
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2019-10-22 17:13:17
 * @Description: 
 -->
<template>
  <el-scrollbar :native="false"
                tag="section"
                class="el-scroll">
    <MetadataRegistrationView :active="active"
                              :treeData="treeData"
                              :defaultProps="defaultProps"
                              ref="MetadataRegis"
                              :findAllSysData="findAllSysData"
                              :exchangeSystemData="exchangeSystemData"
                              :findOrgCatalogTreeData="findOrgCatalogTreeData"
                              :queryLabelTree="queryLabelTree"
                              :DatabaseTypeData="DatabaseTypeData"
                              :driveData="driveData"
                              :ExtractionMethodData="ExtractionMethodData"
                              :findAllSqlData="findAllSqlData"
                              :QueryDictInfoByTypeData="QueryDictInfoByTypeData"
                              :AcquisitionStrategyData="AcquisitionStrategyData"
                              :DataDisclosureMethodData="DataDisclosureMethodData"
                              :DataStorageStrategyData="DataStorageStrategyData"
                              :TableTypeData="TableTypeData"
                              @searchDbVersion="searchDbVersion"
                              :dbVersion="dbVersion"
                              :PreliminaryTypeData="PreliminaryTypeData"
                              :BusinessProcessData="BusinessProcessData"
                              @changeBusinessProcessData="changeBusinessProcessData"
                              :ProcessNodeData="ProcessNodeData"
                              :BusinessRulesData="BusinessRulesData"
                              :findAllInterfaceServerData="findAllInterfaceServerData"
                              :InterfaceTypeData="InterfaceTypeData"
                              :SystemIntensive="SystemIntensive"
                              :findAllInterfaceServerDataSearch="findAllInterfaceServerDataSearch"
                              @dbIdChange="dbIdChange"
                              :AffiliatedSystem="AffiliatedSystem"
                              @changeSystemId="changeSystemId"
                              :findFileServerBySystemIdData="findFileServerBySystemIdData"
                              :SharingMethod="SharingMethod"
                              @changeDbVersion="changeDbVersion"
                              :driveDataLinkage="driveDataLinkage"
                              @changeInterfaceForm="changeInterfaceForm"></MetadataRegistrationView>
  </el-scrollbar>
</template>
<script>
import MetadataRegistrationView from "./MetadataRegistrationView"
import metadataRegistrationApi from "@/httpUtils/ExternalManagement/metadataRegistration"
export default {
  name: "MetadataRegistrationLogic",
  components: {
    MetadataRegistrationView
  },
  data () {
    return {
      active: 0,
      treeData: [],
      defaultProps: {
        children: "child",
        label: "name"
      },
      findAllSysData: [],
      exchangeSystemData: [],
      SystemIntensive: [],
      findOrgCatalogTreeData: [],
      queryLabelTree: [],
      DatabaseTypeData: [],
      ExtractionMethodData: [],
      findAllSqlData: [],
      QueryDictInfoByTypeData: [],
      AcquisitionStrategyData: [],
      DataDisclosureMethodData: [],
      DataStorageStrategyData: [],
      BusinessProcessData: [],
      PreliminaryTypeData: [],
      SharingMethod: [],
      ProcessNodeData: [],
      BusinessRulesData: [],
      findAllInterfaceServerData: [],
      findAllInterfaceServerDataSearch: [],
      AffiliatedSystem: [],
      InterfaceTypeData: [],
      findFileServerBySystemIdData: [],
      dbVersion: [],
      TableTypeData: [],
      driveData: [],
      driveDataLinkage: [],
      // treeProp: {
      //   children: 'child',
      //   label: 'name',
      //   value: 'id',
      // },
      // treeProp2: {
      //   children: 'child',
      //   label: 'name',
      //   value: 'id',
      //   multiple: true,

      // },
      // treeProp3: {
      //   children: 'child',
      //   label: 'name',
      //   value: 'id',
      //   multiple: true,
      // },

    };
  },
  created () {
    metadataRegistrationApi.treeData().then(res => {
      this.treeData = res.data.data
      this.$nextTick(() => {
        this.$refs.MetadataRegis.$refs.treeListss.setCurrentKey('2');
      })
    })

    //  查询到所有的父级系统
    metadataRegistrationApi.findAllSys().then(res => {
      this.findAllSysData = res.data.data
    })
    //  汇交系统
    metadataRegistrationApi.exchangeSystem({ typeCode: '1000001320520190' }).then(res => {
      this.exchangeSystemData = res.data.data
    })
    //  系统密级
    metadataRegistrationApi.exchangeSystem({ typeCode: '1000001020219608' }).then(res => {
      this.SystemIntensive = res.data.data
    })
    //  共享方式
    metadataRegistrationApi.exchangeSystem({ typeCode: '1000001043082756' }).then(res => {
      this.SharingMethod = res.data.data
    })
    //  接口类型
    metadataRegistrationApi.exchangeSystem({ typeCode: '1000001681539543' }).then(res => {
      this.InterfaceTypeData = res.data.data
    })
    //  建设部门，使用部门  
    metadataRegistrationApi.findOrgCatalogTree().then(res => {
      console.log(res.data.data)
      this.IterationDelateMenuChildren(res.data.data)
      // for (let item in res.data.data) {
      //   this.IterationDelateMenuChildren(res.data.data[item].child, 'child')
      // }
      this.findOrgCatalogTreeData = res.data.data
      console.log('!!!', this.findOrgCatalogTreeData)

    })
    //  标签管理
    metadataRegistrationApi.queryLabelTree().then(res => {
      this.IterationDelateMenuChildren(res.data.data)
      this.queryLabelTree = res.data.data

    })
    //  所属数据库
    metadataRegistrationApi.findAllSql().then(res => {
      this.findAllSqlData = res.data.data
    })
    // 数据库类型
    metadataRegistrationApi.exchangeSystem({ typeCode: '1000000800072811' }).then(res => {
      this.DatabaseTypeData = res.data.data
    })
    //  驱动
    metadataRegistrationApi.exchangeSystem({ typeCode: '1000000196054409' }).then(res => {
      this.driveData = res.data.data
    })
    //  数据抽取方式
    metadataRegistrationApi.exchangeSystem({ typeCode: '1000000046892521' }).then(res => {
      this.ExtractionMethodData = res.data.data
    })
    //  汇交方式
    metadataRegistrationApi.getQueryDictInfoByType({ typeCode: '1000001320520190' }).then(res => {
      this.QueryDictInfoByTypeData = res.data.data
    })
    //  数据采集策略
    metadataRegistrationApi.AcquisitionStrategy({ typeCode: '1000001351301850' }).then(res => {
      this.AcquisitionStrategyData = res.data.data
    })
    //  数据公开方式
    metadataRegistrationApi.DataDisclosureMethod({ typeCode: '1000001124128061' }).then(res => {
      this.DataDisclosureMethodData = res.data.data
    })
    //  数据储存类型
    metadataRegistrationApi.DataStorageStrategy({ typeCode: '1000000301862824' }).then(res => {
      this.DataStorageStrategyData = res.data.data
    })
    //  业务流程
    metadataRegistrationApi.BusinessProcess().then(res => {
      this.BusinessProcessData = res.data.data.list
    })
    //表类型
    metadataRegistrationApi.TableType({ typeCode: '1000001287434079' }).then(res => {
      this.TableTypeData = res.data.data
    })
    //  初步类型
    metadataRegistrationApi.PreliminaryType({ typeCode: '1000001974625990' }).then(res => {
      this.PreliminaryTypeData = res.data.data
    })
    //  查询所有的接口服务器
    metadataRegistrationApi.findAllInterfaceServer().then(res => {
      this.findAllInterfaceServerData = res.data.data
    })

  },
  mounted () {

  },
  methods: {
    //  数据库版本
    searchDbVersion (data) {
      console.log('我连解冻了', data)// id
      metadataRegistrationApi.queryInfoByDictId({ dictId: data }).then(res => {
        this.dbVersion = res.data.data
      })
    },
    //  业务流程--获取流程节点数据
    changeBusinessProcessData (data) {
      console.log(data)
      //  获取流程节点数据
      metadataRegistrationApi.ProcessNode({ versionId: data }).then(res => {
        this.ProcessNodeData = res.data.data
      })
    },
    //  业务流程--业务规则
    changenodeId (data) {
      console.log(data)
      //  获取流程节点数据
      metadataRegistrationApi.BusinessRules({ busiNodeId: data }).then(res => {
        this.BusinessRulesData = res.data.data
      })
    },
    //  根据所属数据库查询所属系统
    dbIdChange (id) {
      console.log(id)
      metadataRegistrationApi.findSysByDbId({ dbId: id }).then(res => {
        this.AffiliatedSystem = res.data.data
      })

    },
    //  根据所属数据库查询所属系统
    changeSystemId (id) {
      console.log(id)
      metadataRegistrationApi.findFileServerBySystemId({ systemId: id }).then(res => {
        this.findFileServerBySystemIdData = res.data.data
      })

    },
    //  数据库版本联动获取驱动信息
    changeDbVersion (id) {
      console.log(id)
      metadataRegistrationApi.queryInfoByDictId({ dictId: id }).then(res => {
        this.driveDataLinkage = res.data.data
      })
    },
    //  所属系统联动查询所属接口服务器
    changeInterfaceForm (id) {
      metadataRegistrationApi.findInterfaceSerBySystemId({ systemId: id }).then(res => {
        this.findAllInterfaceServerDataSearch = res.data.data
      })
    }
  }
};
</script>
<style lang="less" scoped>
@import url("./MetadataRegistration.less");
</style>